package com.eric.common.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class FileStats {
	public static void main (String args[]) throws IOException {
		String segFile = "/home/eric/文档/eelly/Analytics/bbs_posts/parse_source.txt";
		FileStats fstats = new FileStats();
		FileReader fileReader = new FileReader(segFile);
	    BufferedReader br = new BufferedReader(fileReader);
		List<String> li = new ArrayList<String>();
		String line;
		while ((line=br.readLine()) != null){
			li.add(line);
		}
		System.out.println(fstats.CountLines(segFile));
		System.out.println(li.size());
		br.close();
	}
	public int CountLines (String fileName) throws IOException {
		FileReader fileReader = new FileReader(fileName);
	    BufferedReader br = new BufferedReader(fileReader);
	    int n = 0;
	       while (br.readLine() != null)
	    	   n++;
	    br.close();
	    return n;
	}
	public int CountLines (File file) throws IOException {
		FileReader fileReader = new FileReader(file);
	       BufferedReader br = new BufferedReader(fileReader);
	       int n = 0;
	       while (br.readLine() != null)
	    	   n++;
	    br.close();
	    return n;
	}
}
